﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;
using System.Net;
using System.IO;
using System.Web;
using System.Diagnostics;

using ConsoleApplication1.Submitters;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            SPOJSubmitter spoj = new SPOJSubmitter();
            spoj.submit();

            /*
            // Create a request using a URL that can receive a post. 
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://uva.onlinejudge.org/index.php?option=com_comprofiler&task=login");
            string submissionPath = "http://unva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=25&page=save_submission";

            request.Method = "POST";
       //     request.Method = "GET";

            StreamReader sr = new StreamReader("source.cpp");
            string source = sr.ReadToEnd();

        //    Console.WriteLine(source);

            source = HttpUtility.UrlEncode(source);

            string []submitData = {"localid=100", "code=ads", "langueage=3"};

            string []loginData = {"username=FreezingCool", "password=and1springs", "op2=login", "lang=english", "force_session=1", "return=B:aHR0cDovL3V2YS5vbmxpbmVqdWRnZS5vcmcv",
                                     "message=0", "loginfrom=loginmodule", "cbsecuritym3=cbm_20e90011_031ff173_e62175aeb6fa0ba2ee363dd044e00fd4", "j1855ca22b75857efcc9b4214fbc45fad=1",
                                     "remember=yes", "Submit=Login"};

            string[] data = { "lang=41", "file=" + source, "problemcode=TEST", "submit=Send", "login_user=montano", "password=montanovpass"};
            // Create POST data and convert it to a byte array.
            string postData = loginData[0];

            for (int i = 1; i < loginData.Length; i++)
            {
                postData += "&" + loginData[i];
            }

            byte[] byteArray = Encoding.UTF8.GetBytes(postData);

            // Set the ContentType property of the WebRequest.
            request.ContentType = "application/x-www-form-urlencoded";
            request.ContentLength = byteArray.Length;

            // Get the request stream.
            Stream dataStream = request.GetRequestStream();
            dataStream.Write(byteArray, 0, byteArray.Length);
            dataStream.Close();

            // Get the response.
            CookieContainer CC = new CookieContainer();
            request.CookieContainer = CC;
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();

            Console.WriteLine("----- COOKIES -----\n");
            if (response.Cookies != null && response.Cookies.Count != 0)
            {
                foreach (Cookie c in response.Cookies)
                {
                 Console.WriteLine("  Cookie: {0} = {1}", c.Name, c.Value);
                }
            }
            else
            {
                Console.WriteLine("No Cookies");
            }

            // Get the stream containing content returned by the server.
            dataStream = response.GetResponseStream();

            // Open the stream using a StreamReader for easy access.
            StreamReader reader = new StreamReader(dataStream);

            // Read the content.
            string responseFromServer = reader.ReadToEnd();

            // Clean up the streams.
            reader.Close();
            dataStream.Close();
            response.Close();



            int b = Console.Read();

            request.
            request.Host = submissionPath;*/
        }
    }
}
